package cn.btks.resultintegration.achievements.controller;

import cn.btks.commonserver.result.ResultState;
import cn.btks.commonserver.result.StateInfo;
import cn.btks.resultintegration.achievements.pojo.Achievements;
import cn.btks.resultintegration.achievements.pojo.VectorFileCategory;
import cn.btks.resultintegration.achievements.service.VectorFileCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author lijun
 * @Date 2021/2/20 15:42
 */
@Slf4j
@RestController
@RequestMapping("api/v1.0/resultIntegration/achievements/achievementsUniversal")
@Api(tags = "成果整合模块")
@Validated
public class VectorFileCategoryController {

    @Autowired
    VectorFileCategoryService vectorFileCategoryService;

    @GetMapping("/verified/findAll")
    @ApiOperation("查询所有矢量文件类型字典表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findAll() {
        List<VectorFileCategory> vectorFileCategoryList = vectorFileCategoryService.findAll();
        return vectorFileCategoryList != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), vectorFileCategoryList) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }

    @GetMapping("/verified/findById/{id}")
    @ApiOperation("根据ID查询矢量文件类型字典项")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "id", value = "矢量文件类型字典项ID", required = true, dataType = "long"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string")
    })
    public ResultState findById(@PathVariable("id") Long id) {
        VectorFileCategory vectorFileCategory = vectorFileCategoryService.findById(id);
        return vectorFileCategory != null ? new ResultState(StateInfo.FIND_OK.getCode(),
                StateInfo.FIND_OK.getMsg(), vectorFileCategory) : new ResultState(StateInfo.FIND_NULL.getCode(),
                StateInfo.FIND_NULL.getMsg());
    }
}
